#pragma once
#include <base.h>

/* 等待计数器 */
typedef hword_t	waitcnt_t;
/* order */
typedef enum {
	LRLX,
	LACQ
} acq_ord_t;

typedef enum {
	RRLX,
	RREL
} rel_ord_t;

/* lock api */
typedef void lock_t;
typedef void *locktoken_t;
/* lock word 定义成unsigned int可以使用futex */
typedef unsigned int lkword_t;

/* lock infun是不需要的 */
STA_OUFUN(lock)
lock_t * (* const init) (void *ptr, size_t size);
void * (* const destruct) (lock_t *lock);
bool_t (* const lock) (lock_t *lock, locktoken_t *ptoken);
bool_t (* const unlock) (lock_t *lock, locktoken_t token);
bool_t (* const lock_relax) (lock_t *lock, locktoken_t *ptoken);
bool_t (* const unlock_relax) (lock_t *lock, locktoken_t token);
END_OUFUN(lock)

/* 所需要提供的函数 */
STA_OUFUN(timed_lock)
lock_t * (* const init) (void *ptr, size_t size);
void * (* const destruct) (lock_t *lock);
bool_t (* const timed_lock) (lock_t *lock, locktoken_t *ptoken, waitcnt_t cnt);
bool_t (* const timed_unlock) (lock_t *lock, locktoken_t token, waitcnt_t cnt);
END_OUFUN(timed_lock)

/* 输出接口 */
